
  
  <template>
  <el-card class="pageScroll">
    <template #header>
      <div class="card-header flex">
        <div class="flex1">投诉管理</div>
      </div>
    </template>
    <el-form
      :model="queryParams"
      ref="queryFormRef"
      :inline="true"
      label-width="68px"
    >
      <el-form-item label="机构名称" prop="organizationId">
        <ApiSelect
          v-model="queryParams.organizationId"
          clearable
          class="!w-240px"
          apiName="organization"
        ></ApiSelect>
      </el-form-item>
      <el-form-item label="反馈时间" prop="time">
        <el-date-picker
          v-model="queryParams.time"
          type="daterange"
          unlink-panels
          range-separator="至"
          start-placeholder="开始日期"
          end-placeholder="结束日期"
        >
        </el-date-picker>
      </el-form-item>
      <el-form-item>
        <el-button @click="handleQuery">搜索</el-button>
        <el-button @click="resetQuery">重置</el-button>
        <el-button type="success" plain @click="onExport()"> 导出 </el-button>
      </el-form-item>
    </el-form>
    <el-table :data="list" :loading="loading">
      <el-table-column label="序号" align="center" prop="_index" />
      <el-table-column label="所属机构" align="center" prop="organizationName">
      </el-table-column>
      <el-table-column label="问题和意见" align="center" prop="feedback">
      </el-table-column>
      <el-table-column label="反馈图片" align="center" prop="imageUrl">
        <template #default="scope">
          <el-image
            style="display: inline-block; width: 100px; margin-right: 4px"
            v-for="item in scope.row.imageUrl || []"
            :src="item.imageUrl"
            :key="item.imageUrl"
          />
        </template>
      </el-table-column>
      <el-table-column label="联系方式" align="center" prop="recipientsPhone">
      </el-table-column>
      <el-table-column label="反馈人" align="center" prop="userName">
      </el-table-column>
      <el-table-column label="反馈时间" align="center" prop="createTime">
      </el-table-column>
      <el-table-column label="操作" fixed="right" align="center">
        <template #default="scope">
          <el-button
            link
            type="primary"
            @click="toViewPage(scope.row.id)"
            v-hasPermi="['infra:config:update']"
          >
            查看
          </el-button>
        </template>
      </el-table-column>
    </el-table>
    <!-- 分页 -->
    <el-pagination :="pagination" class="padding10" />
  </el-card>
</template>
  
<script setup lang="ts">
import API from '@/api/api';
import { CONST_VALUE } from '@/utils/const';
import { useTablePage } from '@/hooks/useTablePage';
import { download } from '@/utils/download';
import dayjs from 'dayjs';
import { transformTime } from '@/utils/transformTime';

const router = useRouter();
const {
  queryParams,
  queryFormRef,
  loading,
  total,
  list,
  handleQuery,
  resetQuery,
  handleDelete,
  pagination,
  exportHandle,
} = useTablePage({
  queryApi: API.feedbackController.list,
  exportApi: API.feedbackController.export,
  transformQueryParams: transformTime,
});

function toEditPage(id?: number) {
  router.push({
    name: 'editEcology',
    query: {
      id,
    },
  });
}

function toViewPage(id?: number) {
  router.push({
    name: 'infoComplain',
    query: {
      id,
    },
  });
}
function onExport() {
  exportHandle({
    fileName: '投诉列表',
  });
}
</script>